package com.lysj.bhp.recharge.repository;


import com.lysj.bhp.recharge.domain.RechargeRecord;
import com.lysj.bhp.recharge.vo.RechargeRecordVo;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;


public interface RechargeRecordRepository extends JpaRepository<RechargeRecord, Long>, JpaSpecificationExecutor {
    List<RechargeRecord> findByUserId(Long userId);

    @Query("SELECT new com.lysj.bhp.recharge.vo.RechargeRecordVo(a.rechargeRecordId,a.userId,a.coinType,a.payAmount,a.createTime,b.email) from  RechargeRecord a, User b  where a.userId = b.userId  order by a.createTime desc ")
    List<RechargeRecordVo> findRechargeRecord();


    List<RechargeRecord> findByCreateTimeBetween(Date beginDate, Date endDate);

    List<RechargeRecord> findByUserIdAndCoinTypeOrderByCreateTimeDesc(Long userId, int coinType, Pageable pageable);

    List<RechargeRecord> findByUserIdOrderByCreateTimeDesc(Long userId, Pageable pr);

    int countByUserIdAndCoinType(Long userId, int coinType);

    List<RechargeRecord> findByUserIdOrderByCreateTimeDesc(Long userId);

    List<RechargeRecord> findByUserIdAndCoinTypeOrderByCreateTimeDesc(Long userId, int coinType);



}
